<template>
    <div class="">
        <el-button v-bind="$attrs" type="primary" @click="handleUpload">上传</el-button>
    </div>
</template>

<script lang="ts" setup>
    import {withDefaults,defineProps} from 'vue'

    interface propsInterface {
        accept?: string,
        multiple?: boolean
    }

    const props = withDefaults(defineProps<propsInterface>(),{
        accept: '*',
        multiple: false
    })

    const handleUpload = ():void => {
        let input:HTMLInputElement | null = document.createElement('input');
        input.type = 'file';
        input.accept = props.accept;
        input.multiple = props.multiple;
        input.click();

        input.onchange = ():void => {
            console.log(input?.files);

            input = null
        }
    }
</script>
<script lang="ts">
    import {defineComponent} from 'vue'
    export default defineComponent({
        name: 'upload-btn'
    })
</script>

<style scoped>

</style>